<script>
	export default {
		globalData: {
			reInit: false, //uni.switchTab跳转后是否要重新执行一次页面更新,onShow判断
			hasLogin: false //全局变量标识是否已经登陆了
		},
		onLaunch: function() {
			// console.log('App Launch')
			uni.getSystemInfo({
				success: (res) => {
					return 
					let safeAreaHeight = uni.$uv.getProperty(res, 'safeAreaInsets.bottom') || 0;
					uni.safeAreaHeight = safeAreaHeight;
					uni.screenHeight = res.screenHeight;
					uni.screenWidth = res.screenWidth;
					let custom = {
						bottom: 28,
						top: 28,
						width: 0,
						height: 0,
						left: 0,
						right: 0
					};
					//指定平台类型为百度小程序||条小程序||微信小程序
			
					//custom = uni.getMenuButtonBoundingClientRect();
			
					// #ifdef MP-WEIXIN
					custom = wx.getMenuButtonBoundingClientRect();
					// #endif
					// #ifdef MP-QQ
					custom = qq.getMenuButtonBoundingClientRect();
					// #endif
					// #ifdef MP-TOUTIAO
					custom = tt.getMenuButtonLayout();
					// #endif
					// #ifdef MP-BAIDU
					custom = swan.getMenuButtonBoundingClientRect();
					// #endif
					//consolres.log(custom)
					uni.CustomBar = custom.bottom + custom.top - res.statusBarHeight;
					// #ifdef MP-ALIPAY
					uni.CustomBar = res.statusBarHeight + res.titleBarHeight;
					// #endif
					// #ifndef MP
					if (res.platform == 'android') {
						uni.CustomBar = res.statusBarHeight + 44;
					} else {
						uni.CustomBar = res.statusBarHeight + 45;
					}
					// #endif
					// consolres.log(res.statusBarHeight,Vue.prototype.CustomBar)
				}
			});
			//小程序更新检查
			// #ifdef MP
			const updateManager = uni.getUpdateManager();
			updateManager.onCheckForUpdate((res) => {
				// 请求完新版本信息的回调
				if (!res.hasUpdate) {
					console.log('已是最新');
				}
			});
			updateManager.onUpdateReady((res) => {
				updateManager.applyUpdate();
			});
			updateManager.onUpdateFailed((res) => {
				// 新的版本下载失败
				uni.showToast({
					title: '更新失败',
					duration: 2000,
					complete: function() {
						uni.hideToast();
					}
				});
			});
			// #endif
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		},
		onPageNotFound: (e) => {
			uni.showToast({
				icon: 'error',
				title: '页面不存在',
				complete: () => {
					uni.switchTab({
						url: '/pages/bars/index',
						animationType: 'none'
					});
				}
			});
		},
		
		
	}
</script>

<style  lang="scss">
	/*每个页面公共css */
	@import "uview-ui/index.scss";
	@import '@/static/css/public.scss';
	// @import '@/uni_modules/uv-ui-tools/index.scss';
	@import '@/static/css/my.scss';
</style>
